<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>编辑商家</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/bootstrap/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            padding: 20px;
        }
        .form-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            max-width: 500px;
            margin: 0 auto;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        .form-group input, .form-group select, .form-group textarea {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .form-group input[type="submit"] {
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;
        }
        .form-group input[type="submit"]:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="form-container">
        <h2>编辑商家</h2>
        <form action="${pageContext.request.contextPath}/shangjia/update" method="post" enctype="multipart/form-data">
            <input type="hidden" name="business_id" value="${business.business_id}">
            <div class="form-group">
                <label for="businessName">商家名称</label>
                <input type="text" id="businessName" name="business_name" value="${business.business_name}" required>
            </div>
            <div class="form-group">
                <label for="businessDesc">商家描述</label>
                <textarea id="businessDesc" name="business_desc" rows="3" class="form-control">${business.business_desc}</textarea>
            </div>
            <div class="form-group">
                <label for="businessContact">联系人</label>
                <input type="text" id="businessContact" name="business_contact" value="${business.business_contact}" required>
            </div>
            <div class="form-group">
                <label for="businessPhone">联系电话</label>
                <input type="text" id="businessPhone" name="business_phone" value="${business.business_phone}" required>
            </div>
            <div class="form-group">
                <label for="businessStatus">状态</label>
                <select id="businessStatus" name="is_delete" required>
                    <option value="1" <c:if test="${business.is_delete == 0}">selected</c:if>>正常</option>
                    <option value="0" <c:if test="${business.is_delete == 1}">selected</c:if>>停用</option>
                </select>
            </div>
<%--            <div class="form-group">--%>
<%--                <label for="businessImage">商家图片</label>--%>
<%--                <input type="file" id="businessImage" name="business_image" accept="image/*">--%>
<%--                <!-- 图片预览区域 -->--%>
<%--                <div id="image-preview" style="margin-top: 10px;">--%>
<%--                    <c:if test="${not empty business.business_image}">--%>
<%--                        <img src="${pageContext.request.contextPath}/uploads/${business.business_image}" width="100" height="100" alt="当前商家图片">--%>
<%--                    </c:if>--%>
<%--                </div>--%>
<%--            </div>--%>
            <div class="form-group">
                <input type="submit" value="更新">
                <button type="button" class="btn btn-default" onclick="window.history.back()">返回</button>
            </div>
        </form>
    </div>

<%--    <script>--%>
<%--        // 图片上传预览功能--%>
<%--        document.getElementById('businessImage').addEventListener('change', function(event) {--%>
<%--            var preview = document.getElementById('image-preview');--%>
<%--            preview.innerHTML = ''; // 清空之前的预览--%>

<%--            var files = event.target.files;--%>
<%--            for (var i = 0; i < files.length; i++) {--%>
<%--                var file = files[i];--%>
<%--                var reader = new FileReader();--%>

<%--                reader.onload = (function(file) {--%>
<%--                    return function(e) {--%>
<%--                        var img = document.createElement('img');--%>
<%--                        img.src = e.target.result;--%>
<%--                        img.style.width = '100px';--%>
<%--                        img.style.height = '100px';--%>
<%--                        img.style.margin = '5px';--%>
<%--                        preview.appendChild(img);--%>
<%--                    };--%>
<%--                })(file);--%>

<%--                reader.readAsDataURL(file);--%>
<%--            }--%>
<%--        });--%>
<%--    </script>--%>
</body>
</html>
